#include "wnd_api.h"

BOOL JOUI::IWndCreate(IWnd** r_IWnd)
{
	ExAutoPtr<ExWnd> IWnd = new ExWnd();
	return IWnd->QueryInterface(r_IWnd) == S_OK;
}

JOUI::ExWnd::~ExWnd()
{
	//UIWnd::Close();
}

BOOL CALLAPI JOUI::ExWnd::Layout_Init(INT nType)
{
	return UIWnd::Layout_Init(nType);
}

BOOL CALLAPI JOUI::ExWnd::Layout_Update()
{
	return UIWnd::Layout_Update();
}

INT CALLAPI JOUI::ExWnd::Layout_GetType()
{
	return UIWnd::Layout_GetType();
}

BOOL CALLAPI JOUI::ExWnd::Layout_SetChildProp(LPVOID parent, INT dwPropID, size_t pvValue)
{
	return UIWnd::Layout_SetChildProp((UIControl*)parent, dwPropID, pvValue);
}

BOOL CALLAPI JOUI::ExWnd::Layout_SetProp(INT dwPropID, size_t pvValue)
{
	return UIWnd::Layout_SetProp(dwPropID, pvValue);
}

BOOL CALLAPI JOUI::ExWnd::Layout_Absolute_Lock(LPVOID hObjChild, INT tLeft, INT tTop, INT tRight, INT tBottom, INT tWidth, INT tHeight)
{
	return UIWnd::Layout_Absolute_Lock((UIControl*)hObjChild, tLeft, tTop, tRight, tBottom, tWidth, tHeight);
}

BOOL CALLAPI JOUI::ExWnd::Layout_Absolute_Setedge(LPVOID hObjChild, INT dwEdge, INT dwType, size_t nValue)
{
	return UIWnd::Layout_Absolute_Setedge((UIControl*)hObjChild, dwEdge, dwType, nValue);
}

BOOL CALLAPI JOUI::ExWnd::Layout_AddChild(LPVOID parent)
{
	return UIWnd::Layout_AddChild((UIControl*)parent);
}

BOOL CALLAPI JOUI::ExWnd::Layout_AddChildren(BOOL fDesc, LPCWSTR dwObjClass, INT* nCount)
{
	return UIWnd::Layout_AddChildren(fDesc, dwObjClass, nCount);
}

BOOL CALLAPI JOUI::ExWnd::Layout_DeleteChild(LPVOID parent)
{
	return UIWnd::Layout_DeleteChild((UIControl*)parent);
}

BOOL CALLAPI JOUI::ExWnd::Layout_DeleteChildren(LPCWSTR dwObjClass)
{
	return UIWnd::Layout_DeleteChildren(dwObjClass);
}

BOOL CALLAPI JOUI::ExWnd::CreateWnd(INT x, INT y, INT width, INT height, LPCWSTR lpwzWindowName, INT dwStyle, INT dwStyleEx, DWORD dwUIStyle, HWND hWndParent, LPCWSTR lpwzClassName, LPARAM lParam, WinMsgPROC lpfnMsgProc)
{
	return CreateUIWnd(x, y, width, height, lpwzWindowName, dwStyle, dwStyleEx, dwUIStyle, hWndParent, lpwzClassName, lParam, lpfnMsgProc);
}

void CALLAPI JOUI::ExWnd::Close(BOOL nRet)
{
	UIWnd::Close(nRet);
}

LPVOID CALLAPI JOUI::ExWnd::GetHandle()
{
	return UIWnd::GetUIWnd();
}

WORD CALLAPI JOUI::ExWnd::RegClass(LPCWSTR lpwzClassName, HICON hIcon, HICON hIconsm)
{
	return UIWnd::RegClass(lpwzClassName, hIcon, hIconsm);
}

void CALLAPI JOUI::ExWnd::CenterFrom()
{
	UIWnd::CenterFrom();
}

HWND CALLAPI JOUI::ExWnd::GethWnd()
{
	return UIWnd::GethWnd();
}

HWND CALLAPI JOUI::ExWnd::GethWndParent()
{
	return UIWnd::GethWndParent();
}

void CALLAPI JOUI::ExWnd::GetClientRect(RECT& lpClientRect)
{
	UIWnd::GetClientRect(lpClientRect);
}

void CALLAPI JOUI::ExWnd::GetRect(RECT& lptRect)
{
	UIWnd::GetRect(lptRect);
}

LPVOID CALLAPI JOUI::ExWnd::GetFromUIWnd(HWND hWnd)
{
	return UIWnd::GetFromUIWnd(hWnd);
}

LPARAM CALLAPI JOUI::ExWnd::GetlParam()
{
	return UIWnd::GetlParam();
}

void CALLAPI JOUI::ExWnd::SetlParam(LPARAM dwlParam)
{
	UIWnd::SetlParam(dwlParam);
}

INT CALLAPI JOUI::ExWnd::GetKeys()
{
	return UIWnd::GetKeys();
}

INT CALLAPI JOUI::ExWnd::Flags(INT dwFlags)
{
	return UIWnd::Flags(dwFlags);
}

LPVOID CALLAPI JOUI::ExWnd::GetToolrack(BOOL iRrack)
{
	return UIWnd::GetToolrack(iRrack);
}

BOOL CALLAPI JOUI::ExWnd::Show(INT nCmdShow)
{
	return UIWnd::Show(nCmdShow);
}

BOOL CALLAPI JOUI::ExWnd::IsVisible()
{
	return UIWnd::IsVisible();
}

void CALLAPI JOUI::ExWnd::SetMinTrackSize(INT MinWidth, INT MinHeight)
{
	UIWnd::SetMinTrackSize(MinWidth, MinHeight);
}

BOOL CALLAPI JOUI::ExWnd::SetText(LPCWSTR lpString, BOOL fTleRedraw)
{
	return UIWnd::SetText(lpString, fTleRedraw);
}

LPCWSTR CALLAPI JOUI::ExWnd::GetText(BOOL fTleGet)
{
	return UIWnd::GetText(fTleGet);
}

LPVOID CALLAPI JOUI::ExWnd::FindUIView(LPCWSTR lpName)
{
	return UIWnd::FindUIView(lpName);
}

DWORD CALLAPI JOUI::ExWnd::UIStyle(DWORD wwsStyle, BOOL dwNewlong)
{
	return UIWnd::UIStyle(wwsStyle, dwNewlong);
}

INT CALLAPI JOUI::ExWnd::Style(INT dwStyle)
{
	return UIWnd::Style(dwStyle);
}

INT CALLAPI JOUI::ExWnd::StyleEx(INT dwStyleEx)
{
	return UIWnd::StyleEx(dwStyleEx);
}

BOOL CALLAPI JOUI::ExWnd::Move(INT x, INT y, INT width, INT height, BOOL bRepaint)
{
	return UIWnd::Move(x, y, width, height, bRepaint);
}

void CALLAPI JOUI::ExWnd::Update(BOOL bUpdate)
{
	UIWnd::Update(bUpdate);
}

void CALLAPI JOUI::ExWnd::SetShadowColor(INT dwColor, INT fSize)
{
	UIWnd::SetShadowColor(dwColor, fSize);
}

void CALLAPI JOUI::ExWnd::SetBorderColor(INT dwColor, INT fSize)
{
	UIWnd::SetBorderColor(dwColor, fSize);
}

void CALLAPI JOUI::ExWnd::SetBackgColor(INT dwColor)
{
	UIWnd::SetBackgColor(dwColor);
}

BOOL CALLAPI JOUI::ExWnd::SetBackgImageFromMemory(LPVOID lpImage, size_t dwImageLen, INT x, INT y, DWORD dwRepeat, RECT* lpGrid, INT dwFlags, DWORD dwAlpha)
{
	return UIWnd::SetBackgImage(lpImage, dwImageLen, x, y, dwRepeat, lpGrid, dwFlags, dwAlpha);
}

BOOL CALLAPI JOUI::ExWnd::SetBackgImageFromHandle(UIimage hImage, BOOL fReset, INT x, INT y, DWORD dwRepeat, RECT* lpGrid, INT dwFlags, DWORD dwAlpha)
{
	return UIWnd::SetBackgImage((UIImage*)hImage, fReset, x, y, dwRepeat, lpGrid, dwFlags, dwAlpha);
}

BOOL CALLAPI JOUI::ExWnd::SetBackgImageFromFile(LPCWSTR lpImagefile, INT x, INT y, DWORD dwRepeat, RECT* lpGrid, INT dwFlags, DWORD dwAlpha)
{
	return UIWnd::SetBackgImage(lpImagefile, x, y, dwRepeat, lpGrid, dwFlags, dwAlpha);
}

void CALLAPI JOUI::ExWnd::SetBackgInfo(INT x, INT y, DWORD dwRepeat, RECT* lpGrid, INT dwFlags, DWORD dwAlpha)
{
	UIWnd::SetBackgInfo(x, y, dwRepeat, lpGrid, dwFlags, dwAlpha);
}

BOOL CALLAPI JOUI::ExWnd::SetBackgPlay(BOOL fPlayFrames, BOOL fResetFrame)
{
	return UIWnd::SetBackgPlay(fPlayFrames, fResetFrame);
}

void CALLAPI JOUI::ExWnd::SetIme(BOOL bEnable)
{
	UIWnd::SetIme(bEnable);
}

void CALLAPI JOUI::ExWnd::SetRadius(INT radius)
{
	UIWnd::SetRadius(radius);
}

INT CALLAPI JOUI::ExWnd::GetRadius()
{
	return UIWnd::GetRadius();
}

void CALLAPI JOUI::ExWnd::SetAlpha(INT fAlpha)
{
	UIWnd::SetAlpha(fAlpha);
}

void CALLAPI JOUI::ExWnd::SetCaptionInfo(info_objcaptionEx* Info)
{
	info_objcaption Info_f{};
	std::memcpy(&Info_f, Info, sizeof(info_objcaptionEx));
	Info_f.imgbutton_close = (UIImage*)Info->imgbutton_close;
	Info_f.imgbutton_max = (UIImage*)Info->imgbutton_max;
	Info_f.imgbutton_restore = (UIImage*)Info->imgbutton_restore;
	Info_f.imgbutton_min = (UIImage*)Info->imgbutton_min;
	Info_f.imgbutton_menu = (UIImage*)Info->imgbutton_menu;
	Info_f.imgbutton_skin = (UIImage*)Info->imgbutton_skin;
	Info_f.imgbutton_setting = (UIImage*)Info->imgbutton_setting;
	Info_f.imgbutton_help = (UIImage*)Info->imgbutton_help;
	Info_f.hicon = Info->hicon;
	Info_f.titlebHeight = Info->titlebHeight;
	Info_f.pfnSubmsg = Info->pfnSubmsg;
	Info_f.Fontinfo = Info->Fontinfo;
	Info_f.crTitle = Info->crTitle;
	Info_f.crBkg = Info->crBkg;
	Info_f.crbutton_normal = Info->crbutton_normal;
	Info_f.crbutton_hover = Info->crbutton_hover;
	Info_f.crbutton_down = Info->crbutton_down;
	Info_f.crBkgbutton_normal = Info->crBkgbutton_normal;
	Info_f.crBkgbutton_hover = Info->crBkgbutton_hover;
	Info_f.crBkgbutton_down = Info->crBkgbutton_down;
	if (Info->lpszFontfamily)
	{
		size_t i = lstrlenW((LPCWSTR)Info->lpszFontfamily);
		if (i > 0)
		{
			RtlMoveMemory((LPVOID)Info_f.lpszFontfamily, Info->lpszFontfamily, i * 2 + 2);
		}
	}
	else
		Info_f.lpszFontfamily = NULL;
	Info_f.dwFontsize = Info->dwFontsize;
	Info_f.dwFontstyle = Info->dwFontstyle;
	Info_f.dwTextFormat = Info->dwTextFormat;

	UIWnd::SetCaptionInfo(&Info_f);
}

LPVOID CALLAPI JOUI::ExWnd::GetCaptionInfo(info_objcaptionEx& Info, INT uType)
{
	info_objcaption Info_f{};
	auto rel = UIWnd::GetCaptionInfo(Info_f, uType);

	info_objcaptionEx Info_s{};
	std::memcpy(&Info_s, &Info_f, sizeof(info_objcaptionEx));

	Info_s.crTitle = Info_f.crTitle.GetARGB();
	Info_s.crBkg = Info_f.crBkg.GetARGB();
	Info_s.crbutton_normal = Info_f.crbutton_normal.GetARGB();
	Info_s.crbutton_hover = Info_f.crbutton_hover.GetARGB();
	Info_s.crbutton_down = Info_f.crbutton_down.GetARGB();
	Info_s.crBkgbutton_normal = Info_f.crBkgbutton_normal.GetARGB();
	Info_s.crBkgbutton_hover = Info_f.crBkgbutton_hover.GetARGB();
	Info_s.crBkgbutton_down = Info_f.crBkgbutton_down.GetARGB();
	Info = Info_s;
	return rel;
}

void CALLAPI JOUI::ExWnd::SetBlur(FLOAT fDeviation, BOOL fmodesoft, BOOL bRedraw)
{
	UIWnd::SetBlur(fDeviation, fmodesoft, bRedraw);
}

INT CALLAPI JOUI::ExWnd::PopupMsg(LPCWSTR lpText, LPCWSTR lpTitle, INT uType, LPCWSTR lpCheckBox, BOOL* lpCheckBoxChecked, INT dwUIStyle, INT crText, INT crBackground, LPVOID dwButfig, INT dwMilliseconds, WinMsgPROC lpfnMsgProc)
{
	return UIWnd::PopupMsg(lpText, lpTitle, uType, lpCheckBox, lpCheckBoxChecked, dwUIStyle, crText, crBackground, dwButfig, dwMilliseconds, lpfnMsgProc);
}

BOOL CALLAPI JOUI::ExWnd::PopupTrayIcon(LPCWSTR lpwzInfo, LPCWSTR lpwzInfoTitle, INT dwInfoFlags)
{
	return UIWnd::PopupTrayIcon(lpwzInfo, lpwzInfoTitle, dwInfoFlags);
}

HRESULT CALLAPI JOUI::ExWnd::ToImage(UIimage& dstImg, BOOL cdraw)
{
	UIImage* tmp = nullptr;
	HRESULT hr = UIWnd::ToImage(&tmp, cdraw);
	dstImg = tmp;
	return hr;
}

UINT CALLAPI JOUI::ExWnd::GetLastFPS()
{
	return UIWnd::GetLastFPS();
}

void CALLAPI JOUI::ExWnd::SetRenderMode(bool active)
{
	UIWnd::SetRenderMode(active);
}

void CALLAPI JOUI::ExWnd::MessageLoop()
{
	UIWnd::MessageLoop();
}

